<!DOCTYPE html>
<html>
and ends with <html>
<body>
<h1>
to <h6>
tags.
<h1>
defines the most important heading. <h6>
defines the least
important heading
p
tag<a>
tag <img>
tag<src>
),alternative
text(<alt>
),<width>
,and <height>
are
provided as attributes:The HTML elementis everything from the start tag to the end tag:
<tagname>
Content goes here...<tagname>/
Start Tag | Element content | End tag |
---|---|---|
h1 | My first heading | /h1 |
p | My first paragraph | /p |
br | none | none |
<html>
,<body>
,
<h1>
and <p>
)
<br>
tag defines a line break, and is an empty element without a closing tag<a>
tag defines a hyperlink.
The <href>
attribute specifies the URL of the page the link goes to<img>
tag is used to embed an image in an HTML page.The
<src>
attribute specifies the path to the image to be displayed
1. Absolute URL-Links to an external image that is hosted on another website. Example: src="https://www.w3schools.com/images/img_girl.jpg".
Notes:External images might be under copyright. If you do not get permission to use it, you may be in violation of copyright laws. In addition, you cannot control external images; it can suddenly be removed or changed.
2. Relative URL Links to an image that is hosted within the website. Here, the URL does not include the domain name. If the URL begins without a slash, it will be relative to the current page. Example: src="img_girl.jpg". If the URL begins with a slash, it will be relative to the domain. Example: src="/images/img_girl.jpg".
Tip:It is almost always best to use relative URLs. They will not break if you change domain.
<img>
tag should contain <width>
and <height>
attributes,which specify the width and height of the image (in pixels)<alt>
attribute for the <img>
tag specifies an alternate
text for an image, if the image for some reason cannot be displayed. This can be due to a slow connection,
or
an error in the <src>
attribute, or if the user uses a screen reader.<style>
attribute is used to add styles to an element, such as color, font, size, and
more.<title>
attribute defines some extra information about an element.<h1>
to <h6>
tags<h1>
defines the most important heading. <h6>
defines the least
important heading.The HTML <p>
element defines a paragraph.
A paragraph always starts on a new line, and browsers automatically add some white space (a margin) before and
after a paragraph.
<hr>
tag defines a thematic break in an HTML page, and is most often displayed as a
horizontal rule.<hr>
element is used to separate content (or define a change) in an HTML page:<br>
element defines a line break. <br>
if you want a line break (a new line) without starting a new paragraph:<pre>
Element
<pre>
element defines preformatted text.<pre>
element is displayed in a fixed-width font (usually Courier), and
it preserves both spaces and line breaks The HTML <style>
ttribute is used to add styles to an element, such as color, font, size, and
more.
<background-color>
property defines the background color for an HTML element.
<color>
property defines the text color for an HTML element<font-family>
property defines the font to be used for an HTML element<font-size>
property defines the text size for an HTML element<text-align>
property defines the horizontal text alignment for an HTML element
<b>
and <strong>
Elements
<b>
element defines bold text, without any extra importance<strong>
element defines text with strong importance. The content inside is
typically displayed in bold.<i>
and <em>
Elements
<i>
element defines a part of text in an alternate voice or mood. The content
inside is typically displayed in italic.<em>
element defines emphasized text. The content inside is typically displayed
in italic<mark>
- Marked text<small>
- Smaller text<del>
- Delete text<ins>
- Inserted text<sub>
- Subscript text<sup>
- Superscript text<blockquote>
for Quotations
<blockquote>
element defines a section that is quoted from another source.<blockquote>
elements<q>
for Short Quotations
<q>
tag defines a short quotation.<abbr>
for Abbreviations
<abbr>
tag defines an abbreviation or an acronym, like "HTML", "CSS", "Mr.",
"Dr.", "ASAP", "ATM".<address>
for Contact Information
<address>
tag defines the contact information for the author/owner of a document
or an article.<address>
element usually renders in italic, and browsers will always add
a line break before and after the <address>
element.<cites>
for Work Title
<cite>
tag defines the title of a creative work (e.g. a book, a poem, a song, a
movie, a painting, a sculpture, etc.).<cite>
<bdo>
for Bi-Directional Override<bdo>
tag is used to override the current text direction<!--
multi-line
comments
-->
<!--[if IE]>
<p>Conditional Comments, this is only displayed in Internet Explorer </p>
<![endif]-->
<[Tag] Style=" char-color: your-color; [other-attribute];">...
Ex: style="color: #1167af"
Ex: Style ="background-color: rgb(255, 200, 200)"
Ex: style="border: 2px solid hsl(9, 100%, 64%)
<a href="URL" target="your Attribute">your tittles</a>
Basic link
<a href="https://www.google.com/">Basic </a>Absolute URLs include the full web address.
<a href="https://www.google.com/">Absolute </a>Relative URLs point to pages within the same website [ Without domain] so you can't open this link in this page
<a href="daotao.hnmu.edu.vn/Common/ChiTietTin/1836">Relative </a>Send email to daotao@hnmu.edu.vn
<a href="mailto:daotao@hnmu.edu.vn">My email </a>Insert img syntax: <img src="img-url" alt="text">
The HTML <img>
tag is used to embed an image in a web page.
<img>
tag has two required attributes:
<src>
- Specifies the path to the image<alt>
- Specifies an alternate text for the image
<width>
and <height>
can be use as attributes
<img src="https://biz.prlog.org/oneimageinc/logo.jpg" alt="imgage" width="250";height="250";>
Or you can use the <style>
attribute to specify the width and height of an image.
<img src="https://biz.prlog.org/oneimageinc/logo.jpg" alt="imgage"
style="width:250px;height:250px;">
Ex: <img src="/picture/images.png" alt="bruh" style="width:128px;height:128px;">
To point to an image on another server, you must specify an absolute (full) URL in the src attribute:
Ex: <img src="https://biz.prlog.org/oneimageinc/logo.jpg" alt="img">
HTML allows animated GIFs:
Use syntax: <img src="img-name.gif">
To use an image as a link, put the <img>
tag inside the <a>
tag:
Use the CSS float property to let the image float to the right or to the left of a text
Ex:
<img src="https://th.bing.com/th/id/OIP.qkFfVPRGs3lHfF2gNZzUcAHaHa?rs=1&pid=ImgDetMain" alt="Succrose" style="float:inline-start;width:60px;height:auto;">
The image will float to the left-inline of the text
Abbreviation | File Formatt | File Extension |
---|---|---|
APNG | Animated Portable Network Graphics | .apng |
GIF | Graphics Interchange Format | .gif |
ICO | Microsoft Icon | .ico, .cur |
JPEG | Joint Photographic Expert Group image | .jpg, .jpeg, .jfif, .pjpeg, .pjp |
PNG | Portable Network Graphics | .png |
SVG | Scalable Vector Graphics | .svg |
Tag | Description |
---|---|
<img> | Defines an image |
<map> | Defines an image map | >
<area> | Defines a clickable area inside an image map |
<picture> | Defines a container for multiple image resources |
To add a background image on an HTML element, use the HTML style
attribute
and the CSS background-image
property:
Add a background image on a HTML element:
<p style="background-image: url('img-url');">
You can also specify the background image in the <style>
element, in the <head>
section
If the background image is smaller than the element, the image will repeat itself, horizontally and vertically, until it reaches the end of the element
To avoid the background image from repeating itself, set the background-repeat
property
to no-repeat
.
If you want the background image to cover the entire element, you
can set the background-size
property to
cover.
Also, to make sure the entire element is always covered, set the
background-attachment
property to fixed
If you want the background image to stretch to fit the entire element, you
can set the background-size
property to
100% 100%
The HTML <picture>
element allows
you to display different pictures for different devices or screen sizes.
Each table cell is defined by a <td>
and a </td>
tag. and stand for table
data
Ex: <td>cell-data</td>
Each table row starts with a
<tr>
and ends with a </tr>
tag.
Ex:
<tr>
<td>cell-data</td>
</tr>
replace <td>
by <th>
an example:
Header 1 | Header 2 |
---|---|
<cell 1> | cell 2 |
An unordered list starts with the <ul>
tag. Each list item starts with the
<li>
tag.
The list items will be marked with bullets (small black circles) by default:
Ex:
<ul> unordered list
<li>item-1</li>
<li>item-2</li>
</ul>
and this is result:
An ordered list starts with the </ol>
tag. Each list item starts with the
<li>
tag.
The list items will be marked with numbers by default:
Ex:
<ol> ordered list
<li>item-1</li>
<li>item-2</li>
</ol>
and this is result:
The <dl>
tag defines the description list, the <dt>
tag defines the term
(name), and the <dd>
tag describes each term
Ex:
<dl> Description list
<dt>term-1</dt>
<dd>- item-1</dd>
<dt>term-2</dt>
<dd>- item-2</dd>
</dl>
and this is result:
Tag | Description |
---|---|
<ul> | Defines an unordered list |
<ol> | Defines an ordered list | >
<li> | Defines a list item |
<dl> | Defines a description list |
<dt> | Defines a term in a description list |
<dd> | Describes the term in a description list |
<p>
and <div>
<p>
element defines a paragraph in an HTML document.<div>
element defines a division or a section in an HTML document.<span>
element inside a paragraph.<div>
element is often used as a container for other HTML elements.<div>
element has no required attributes, but <style>
,
<class>
and <id>
are common.
<div>
element can be used to style blocks of content
<span>
element is an inline container used to mark up a part of a text, or a part of
a
document.<span>
element has no required attributes,but <style>
,
<class>
and <id>
are common.
<span>
element can be used to style parts of the text